package m.jclecai.com.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import m.jclecai.com.R;

import java.text.DecimalFormat;
import java.util.List;

import m.jclecai.com.bean.ZqCBFItem;
import m.jclecai.com.dialog.BFDialog;
import m.jclecai.com.listener.NotifyTextViewSetChanged;
import m.jclecai.com.utils.Utils;
import m.jclecai.com.utils.http.FastOk;

/**
 * 比分
 * Created by hp on 2017/3/23.
 */

public class ExpandableBFAdapter extends BaseExpandableListAdapter {
    private Context context;

    private List<String> groups;
    List<List<ZqCBFItem>> lists;
    private NotifyTextViewSetChanged changed;
    private BFDialog bfDialog;
    DecimalFormat df = new DecimalFormat("#.00");

    public ExpandableBFAdapter() {

    }

    public ExpandableBFAdapter(Context context, List<String> groups,
                               List<List<ZqCBFItem>> lists, NotifyTextViewSetChanged changed) {
        this.context = context;
        this.groups = groups;
        this.lists = lists;
        this.changed = changed;

    }

    @Override
    public int getGroupCount() {
        return groups.size();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return lists.get(groupPosition).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groups.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return lists.get(groupPosition).get(childPosition);
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        GroupViewHolder groupViewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_parent, null);
            groupViewHolder = new GroupViewHolder(convertView);
            convertView.setTag(groupViewHolder);
        } else {
            groupViewHolder = (GroupViewHolder) convertView.getTag();
        }
        groupViewHolder.list_item_parent_title.setText(groups.get(groupPosition));

        if (isExpanded) {
            groupViewHolder.list_item_parent_icon.setImageResource(R.drawable.cz);
        } else {
            groupViewHolder.list_item_parent_icon.setImageResource(R.drawable.d0);
        }
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        final ChlidViewHolder chlidViewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_zq_bf, null);
            chlidViewHolder = new ChlidViewHolder(convertView);
            convertView.setTag(chlidViewHolder);
        } else {
            chlidViewHolder = (ChlidViewHolder) convertView.getTag();
        }
        final ZqCBFItem item = (ZqCBFItem) getChild(groupPosition, childPosition);
        final String[] codes = item.getStrings();

        chlidViewHolder.away_team_name.setText(Html.fromHtml(codes[4]));
        chlidViewHolder.home_team_name.setText(Html.fromHtml(codes[3]));
        chlidViewHolder.item_name.setText(codes[2]);//世界杯预选赛
        chlidViewHolder.item_time.setText(codes[7].substring(5, 16) + "\n" + codes[1]);

        final List<String[]> rqsflists = FastOk.getList(codes[16], String[].class);


        if (item.getBfStrings().size() != 0) {
            StringBuffer buffer = new StringBuffer();
            for (int i = 0; i < item.getBfStrings().size(); i++) {
                buffer.append(item.getBfStrings().get(i));
                buffer.append(",");
            }
            buffer.deleteCharAt(buffer.length() - 1);
            chlidViewHolder.jczq_select_bf.setText(buffer.toString());
        } else {
            chlidViewHolder.jczq_select_bf.setText("点击选择比分");
        }
        chlidViewHolder.jczq_select_bf.setTag(item);

        chlidViewHolder.jczq_select_bf.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bfDialog = new BFDialog(context, R.style.delete_dialog, new BFDialog.BFDialogListener() {
                    @Override
                    public void onClick(View view) {
                        switch (view.getId()) {
                            case R.id.dialog_confirm:
                                if (item.getBfStrings().size() != 0) {
                                    StringBuffer buffer = new StringBuffer();
                                    for (int i = 0; i < item.getBfStrings().size(); i++) {
                                        buffer.append(item.getBfStrings().get(i));
                                        buffer.append(",");
                                    }
                                    buffer.deleteCharAt(buffer.length() - 1);
                                    chlidViewHolder.jczq_select_bf.setText(buffer.toString());
                                    chlidViewHolder.jczq_select_bf.setTextColor(Color.WHITE);
                                    isAdd(item);
                                } else {
                                    chlidViewHolder.jczq_select_bf.setText("点击选择比分");
                                    chlidViewHolder.jczq_select_bf.setTextColor(Color.WHITE);
                                    isAdd(item);
                                }
                                bfDialog.cancel();
                                break;

                            case R.id.dialog_cancel:
                                bfDialog.cancel();
                                break;
                            case R.id.jczq_bf_10:
                                TextView textView1 = (TextView) view
                                        .findViewById(R.id.jczq_bf_10);
                                if (!item.getBfStrings().contains("1:0")) {
                                    item.getBfStrings().add("1:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[0]);
                                    textView1.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
                                    textView1.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[0]);
                                    textView1.setTextColor(Color.BLACK);
                                    textView1.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_20:
                                TextView textView2 = (TextView) view.findViewById(R.id.jczq_bf_20);
                                if (!item.getBfStrings().contains("2:0")) {
                                    item.getBfStrings().add("2:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[1]);
                                    textView2.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
                                    textView2.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("2:0");
                                    textView2.setTextColor(Color.BLACK);
                                    item.getOdd_sp().remove(rqsflists.get(3)[1]);
                                    textView2.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_21:
                                TextView textView3 = (TextView) view
                                        .findViewById(R.id.jczq_bf_21);
                                if (!item.getBfStrings().contains("2:1")) {
                                    item.getBfStrings().add("2:1");
                                    textView3
                                            .setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    item.getOdd_sp().add(rqsflists.get(3)[2]);
                                    textView3.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("2:1");
                                    textView3.setTextColor(Color.BLACK);
                                    item.getOdd_sp().remove(rqsflists.get(3)[2]);
                                    textView3
                                            .setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_30:
                                TextView textView4 = (TextView) view.findViewById(R.id.jczq_bf_30);
                                if (!item.getBfStrings().contains("3:0")) {
                                    item.getBfStrings().add("3:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[3]);
                                    textView4.setBackgroundColor(android.graphics.Color
                                            .parseColor("#FF0026"));
                                    textView4.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("3:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[3]);
                                    textView4.setTextColor(Color.BLACK);
                                    textView4.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_31:
                                TextView textView5 = (TextView) view
                                        .findViewById(R.id.jczq_bf_31);
                                if (!item.getBfStrings().contains("3:1")) {
                                    item.getBfStrings().add("3:1");
                                    item.getOdd_sp().add(rqsflists.get(3)[4]);
                                    textView5
                                            .setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView5.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("3:1");
                                    item.getOdd_sp().remove(rqsflists.get(3)[4]);
                                    textView5.setTextColor(Color.BLACK);
                                    textView5
                                            .setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_32:
                                TextView textView6 = (TextView) view
                                        .findViewById(R.id.jczq_bf_32);
                                if (!item.getBfStrings().contains("3:2")) {
                                    item.getBfStrings().add("3:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[5]);
                                    textView6.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
                                    textView6.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("3:2");
                                    item.getOdd_sp().remove(rqsflists.get(3)[5]);
                                    textView6.setTextColor(Color.BLACK);
                                    textView6.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_40:
                                TextView textView7 = (TextView) view
                                        .findViewById(R.id.jczq_bf_40);
                                if (!item.getBfStrings().contains("4:0")) {
                                    item.getBfStrings().add("4:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[6]);
                                    textView7.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView7.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("4:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[6]);
                                    textView7.setTextColor(Color.BLACK);
                                    textView7.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_41:
                                TextView textView8 = (TextView) view
                                        .findViewById(R.id.jczq_bf_41);
                                if (!item.getBfStrings().contains("4:1")) {
                                    item.getBfStrings().add("4:1");
                                    item.getOdd_sp().add(rqsflists.get(3)[7]);
                                    textView8.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView8.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("4:1");
                                    item.getOdd_sp().remove(rqsflists.get(3)[7]);
                                    textView8.setTextColor(Color.BLACK);
                                    textView8.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_42:
                                TextView textView9 = (TextView) view
                                        .findViewById(R.id.jczq_bf_42);
                                if (!item.getBfStrings().contains("4:2")) {
                                    item.getBfStrings().add("4:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[8]);
                                    textView9.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView9.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("4:2");
                                    item.getOdd_sp().remove(rqsflists.get(3)[8]);
                                    textView9.setTextColor(Color.BLACK);
                                    textView9.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_50:
                                TextView textView10 = (TextView) view
                                        .findViewById(R.id.jczq_bf_50);
                                if (!item.getBfStrings().contains("5:0")) {
                                    item.getBfStrings().add("5:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[9]);
                                    textView10.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView10.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("5:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[9]);
                                    textView10.setTextColor(Color.BLACK);
                                    textView10.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_51:
                                TextView textView11 = (TextView) view
                                        .findViewById(R.id.jczq_bf_51);
                                if (!item.getBfStrings().contains("5:1")) {
                                    item.getBfStrings().add("5:1");
                                    item.getOdd_sp().add(rqsflists.get(3)[10]);
                                    textView11.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView11.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("5:1");
                                    item.getOdd_sp().remove(rqsflists.get(3)[10]);
                                    textView11.setTextColor(Color.BLACK);
                                    textView11.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_52:
                                TextView textView12 = (TextView) view
                                        .findViewById(R.id.jczq_bf_52);
                                if (!item.getBfStrings().contains("5:2")) {
                                    item.getBfStrings().add("5:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[11]);
                                    textView12.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView12.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("5:2");
                                    item.getOdd_sp().remove(rqsflists.get(3)[11]);
                                    textView12.setTextColor(Color.BLACK);
                                    textView12.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_s_other:
                                TextView textView13 = (TextView) view
                                        .findViewById(R.id.jczq_bf_s_other);
                                if (!item.getBfStrings().contains("9:0")) {
                                    item.getBfStrings().add("9:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[12]);
                                    textView13.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView13.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("9:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[12]);
                                    textView13.setTextColor(Color.BLACK);
                                    textView13.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_00:
                                TextView textView14 = (TextView) view
                                        .findViewById(R.id.jczq_bf_00);
                                if (!item.getBfStrings().contains("0:0")) {
                                    item.getBfStrings().add("0:0");
                                    item.getOdd_sp().add(rqsflists.get(3)[13]);
                                    textView14.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView14.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:0");
                                    item.getOdd_sp().remove(rqsflists.get(3)[13]);
                                    textView14.setTextColor(Color.BLACK);
                                    textView14.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_11:
                                TextView textView15 = (TextView) view
                                        .findViewById(R.id.jczq_bf_11);
                                if (!item.getBfStrings().contains("1:1")) {
                                    item.getBfStrings().add("1:1");
                                    item.getOdd_sp().add(rqsflists.get(3)[14]);
                                    textView15.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView15.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:1");
                                    item.getOdd_sp().remove(rqsflists.get(3)[14]);
                                    textView15.setTextColor(Color.BLACK);
                                    textView15.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_22:
                                TextView textView16 = (TextView) view
                                        .findViewById(R.id.jczq_bf_22);
                                if (!item.getBfStrings().contains("2:2")) {
                                    item.getBfStrings().add("2:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[15]);
                                    textView16.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView16.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("2:2");
                                    item.getOdd_sp().remove(rqsflists.get(3)[15]);
                                    textView16.setTextColor(Color.BLACK);
                                    textView16.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_33:
                                TextView textView17 = (TextView) view
                                        .findViewById(R.id.jczq_bf_33);
                                if (!item.getBfStrings().contains("3:3")) {
                                    item.getBfStrings().add("3:3");
                                    item.getOdd_sp().add(rqsflists.get(3)[16]);
                                    textView17.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView17.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("3:3");
                                    item.getOdd_sp().remove(rqsflists.get(3)[16]);
                                    textView17.setTextColor(Color.BLACK);
                                    textView17.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_p_other:
                                TextView textView18 = (TextView) view
                                        .findViewById(R.id.jczq_bf_p_other);
                                if (!item.getBfStrings().contains("9:9")) {
                                    item.getBfStrings().add("9:9");
                                    item.getOdd_sp().add(rqsflists.get(3)[17]);
                                    textView18.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView18.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("9:9");
                                    item.getOdd_sp().remove(rqsflists.get(3)[17]);
                                    textView18.setTextColor(Color.BLACK);
                                    textView18.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_01:
                                TextView textView19 = (TextView) view
                                        .findViewById(R.id.jczq_bf_01);
                                if (!item.getBfStrings().contains("0:1")) {
                                    item.getBfStrings().add("0:1");
                                    item.getOdd_sp().add(rqsflists.get(3)[18]);
                                    textView19.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView19.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:1");
                                    item.getOdd_sp().remove(rqsflists.get(3)[18]);
                                    textView19.setTextColor(Color.BLACK);
                                    textView19.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_02:
                                TextView textView20 = (TextView) view
                                        .findViewById(R.id.jczq_bf_02);
                                if (!item.getBfStrings().contains("0:2")) {
                                    item.getBfStrings().add("0:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[19]);
                                    textView20.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView20.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:2");
                                    textView20.setTextColor(Color.BLACK);
                                    item.getOdd_sp().remove(rqsflists.get(3)[19]);
                                    textView20.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_12:
                                TextView textView21 = (TextView) view
                                        .findViewById(R.id.jczq_bf_12);
                                if (!item.getBfStrings().contains("1:2")) {
                                    item.getBfStrings().add("1:2");
                                    item.getOdd_sp().add(rqsflists.get(3)[20]);
                                    textView21.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView21.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:2");
                                    item.getOdd_sp().remove(rqsflists.get(3)[20]);
                                    textView21.setTextColor(Color.BLACK);
                                    textView21.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_03:
                                TextView textView22 = (TextView) view
                                        .findViewById(R.id.jczq_bf_03);
                                if (!item.getBfStrings().contains("0:3")) {
                                    item.getBfStrings().add("0:3");
                                    item.getOdd_sp().add(rqsflists.get(3)[21]);
                                    textView22.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView22.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:3");
                                    item.getOdd_sp().remove(rqsflists.get(3)[21]);
                                    textView22.setTextColor(Color.BLACK);
                                    textView22.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_13:
                                TextView textView23 = (TextView) view
                                        .findViewById(R.id.jczq_bf_13);
                                if (!item.getBfStrings().contains("1:3")) {
                                    item.getBfStrings().add("1:3");
                                    item.getOdd_sp().add(rqsflists.get(3)[22]);
                                    textView23.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView23.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:3");
                                    item.getOdd_sp().remove(rqsflists.get(3)[22]);
                                    textView23.setTextColor(Color.BLACK);
                                    textView23.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_23:
                                TextView textView24 = (TextView) view
                                        .findViewById(R.id.jczq_bf_23);
                                if (!item.getBfStrings().contains("2:3")) {
                                    item.getBfStrings().add("2:3");
                                    item.getOdd_sp().add(rqsflists.get(3)[23]);
                                    textView24.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView24.setTextColor(Color.WHITE);
                                } else {
                                    item.getOdd_sp().remove(rqsflists.get(3)[23]);
                                    item.getBfStrings().remove("2:3");
                                    textView24.setTextColor(Color.BLACK);
                                    textView24.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_04:
                                TextView textView25 = (TextView) view
                                        .findViewById(R.id.jczq_bf_04);
                                if (!item.getBfStrings().contains("0:4")) {
                                    item.getBfStrings().add("0:4");
                                    item.getOdd_sp().add(rqsflists.get(3)[24]);
                                    textView25.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView25.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:4");
                                    item.getOdd_sp().remove(rqsflists.get(3)[24]);
                                    textView25.setTextColor(Color.BLACK);
                                    textView25.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_14:
                                TextView textView26 = (TextView) view
                                        .findViewById(R.id.jczq_bf_14);
                                if (!item.getBfStrings().contains("1:4")) {
                                    item.getBfStrings().add("1:4");
                                    item.getOdd_sp().add(rqsflists.get(3)[25]);
                                    textView26.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView26.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:4");
                                    item.getOdd_sp().remove(rqsflists.get(3)[25]);
                                    textView26.setTextColor(Color.BLACK);
                                    textView26.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_24:
                                TextView textView27 = (TextView) view
                                        .findViewById(R.id.jczq_bf_24);
                                if (!item.getBfStrings().contains("2:4")) {
                                    item.getBfStrings().add("2:4");
                                    textView27.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    item.getOdd_sp().add(rqsflists.get(3)[26]);
                                    textView27.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("2:4");
                                    item.getOdd_sp().remove(rqsflists.get(3)[26]);
                                    textView27.setTextColor(Color.BLACK);
                                    textView27.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_05:
                                TextView textView28 = (TextView) view
                                        .findViewById(R.id.jczq_bf_05);
                                if (!item.getBfStrings().contains("0:5")) {
                                    item.getBfStrings().add("0:5");
                                    item.getOdd_sp().add(rqsflists.get(3)[27]);
                                    textView28.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView28.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:5");
                                    item.getOdd_sp().remove(rqsflists.get(3)[27]);
                                    textView28.setTextColor(Color.BLACK);
                                    textView28.setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_15:
                                TextView textView29 = (TextView) view
                                        .findViewById(R.id.jczq_bf_15);
                                if (!item.getBfStrings().contains("1:5")) {
                                    item.getBfStrings().add("1:5");
                                    item.getOdd_sp().add(rqsflists.get(3)[28]);
                                    textView29.setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView29.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("1:5");
                                    item.getOdd_sp().remove(rqsflists.get(3)[28]);
                                    textView29.setTextColor(Color.BLACK);
                                    textView29
                                            .setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_25:
                                TextView textView30 = (TextView) view
                                        .findViewById(R.id.jczq_bf_25);
                                if (!item.getBfStrings().contains("2:5")) {
                                    item.getBfStrings().add("2:5");
                                    item.getOdd_sp().add(rqsflists.get(3)[29]);
                                    textView30
                                            .setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView30.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("2:5");
                                    item.getOdd_sp().remove(rqsflists.get(3)[29]);
                                    textView30.setTextColor(Color.BLACK);
                                    textView30
                                            .setBackgroundColor(Color.WHITE);
                                }
                                break;
                            case R.id.jczq_bf_f_other:
                                TextView textView31 = (TextView) view
                                        .findViewById(R.id.jczq_bf_f_other);
                                if (!item.getBfStrings().contains("0:9")) {
                                    item.getBfStrings().add("0:9");
                                    item.getOdd_sp().add(rqsflists.get(3)[30]);
                                    textView31
                                            .setBackgroundColor(android.graphics.Color
                                                    .parseColor("#FF0026"));
                                    textView31.setTextColor(Color.WHITE);
                                } else {
                                    item.getBfStrings().remove("0:9");
                                    item.getOdd_sp().remove(rqsflists.get(3)[30]);
                                    textView31.setTextColor(Color.BLACK);
                                    textView31
                                            .setBackgroundColor(Color.WHITE);
                                }
                                break;

                        }
                    }
                });
                bfDialog.setCancelable(false);
                bfDialog.setCanceledOnTouchOutside(false);
                // 标题
                TextView title = (TextView) bfDialog.getCustomView().findViewById(R.id.dialog_title);
                title.setText(codes[3] + "　　VS　　" + codes[4]);
                // 胜
                TextView titles1 = (TextView) bfDialog.getCustomView().findViewById(R.id.jczq_bf_10);
                titles1.setText("1:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[0])));
                if (item.getBfStrings().contains("1:0")) {
                    titles1.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles1.setTextColor(Color.WHITE);
                } else {
                    titles1.setTextColor(Color.BLACK);
                    titles1.setBackgroundColor(Color.WHITE);
                }

                TextView titles2 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_20);
                titles2.setText("2:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[1])));
                if (item.getBfStrings().contains("2:0")) {
                    titles2.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles2.setTextColor(Color.WHITE);
                } else {
                    titles2.setTextColor(Color.BLACK);
                    titles2.setBackgroundColor(Color.WHITE);
                }

                TextView titles3 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_21);
                titles3.setText("2:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[2])));
                if (item.getBfStrings().contains("2:1")) {
                    titles3.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles3.setTextColor(Color.WHITE);
                } else {
                    titles3.setTextColor(Color.BLACK);
                    titles3.setBackgroundColor(Color.WHITE);
                }
                TextView titles4 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_30);
                titles4.setText("3:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[3])));
                if (item.getBfStrings().contains("3:0")) {
                    titles4.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles4.setTextColor(Color.WHITE);
                } else {
                    titles4.setTextColor(Color.BLACK);
                    titles4.setBackgroundColor(Color.WHITE);
                }
                TextView titles5 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_31);
                titles5.setText("3:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[4])));
                if (item.getBfStrings().contains("3:1")) {
                    titles5.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles5.setTextColor(Color.WHITE);
                } else {
                    titles5.setTextColor(Color.BLACK);
                    titles5.setBackgroundColor(Color.WHITE);
                }
                TextView titles6 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_32);
                titles6.setText("3:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[5])));
                if (item.getBfStrings().contains("3:2")) {
                    titles6.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles6.setTextColor(Color.WHITE);
                } else {
                    titles6.setTextColor(Color.BLACK);
                    titles6.setBackgroundColor(Color.WHITE);
                }
                TextView titles7 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_40);
                titles7.setText("4:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[6])));
                if (item.getBfStrings().contains("4:0")) {
                    titles7.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles7.setTextColor(Color.WHITE);
                } else {
                    titles7.setTextColor(Color.BLACK);
                    titles7.setBackgroundColor(Color.WHITE);
                }
                TextView titles8 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_41);
                titles8.setText("4:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[7])));
                if (item.getBfStrings().contains("4:1")) {
                    titles8.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles8.setTextColor(Color.WHITE);
                } else {
                    titles8.setTextColor(Color.BLACK);
                    titles8.setBackgroundColor(Color.WHITE);
                }
                TextView titles9 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_42);
                titles9.setText("4:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[8])));
                if (item.getBfStrings().contains("4:2")) {
                    titles9.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles9.setTextColor(Color.WHITE);
                } else {
                    titles9.setTextColor(Color.BLACK);
                    titles9.setBackgroundColor(Color.WHITE);
                }
                TextView titles10 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_50);
                titles10.setText("5:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[9])));
                if (item.getBfStrings().contains("5:0")) {
                    titles10.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles10.setTextColor(Color.WHITE);
                } else {
                    titles10.setTextColor(Color.BLACK);
                    titles10.setBackgroundColor(Color.WHITE);
                }
                TextView titles11 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_51);
                titles11.setText("5:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[10])));
                if (item.getBfStrings().contains("5:1")) {
                    titles11.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles11.setTextColor(Color.WHITE);
                } else {
                    titles11.setTextColor(Color.BLACK);
                    titles11.setBackgroundColor(Color.WHITE);
                }
                TextView titles12 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_52);
                titles12.setText("5:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[11])));
                if (item.getBfStrings().contains("5:2")) {
                    titles12.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles12.setTextColor(Color.WHITE);
                } else {
                    titles12.setTextColor(Color.BLACK);
                    titles12.setBackgroundColor(Color.WHITE);
                }
                TextView titles13 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_s_other);
                titles13.setText("胜其他\n" + df.format(Double.parseDouble(rqsflists.get(3)[12])));
                if (item.getBfStrings().contains("9:0")) {
                    titles13.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titles13.setTextColor(Color.WHITE);
                } else {
                    titles13.setTextColor(Color.BLACK);
                    titles13.setBackgroundColor(Color.WHITE);
                }
                // 平
                TextView titlep1 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_00);
                titlep1.setText("0:0\n" + df.format(Double.parseDouble(rqsflists.get(3)[13])));
                if (item.getBfStrings().contains("0:0")) {
                    titlep1.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlep1.setTextColor(Color.WHITE);
                } else {
                    titlep1.setTextColor(Color.BLACK);
                    titlep1.setBackgroundColor(Color.WHITE);
                }
                TextView titlep2 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_11);
                titlep2.setText("1:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[14])));
                if (item.getBfStrings().contains("1:1")) {
                    titlep2.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlep2.setTextColor(Color.WHITE);
                } else {
                    titlep2.setTextColor(Color.BLACK);
                    titlep2.setBackgroundColor(Color.WHITE);
                }
                TextView titlep3 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_22);
                titlep3.setText("2:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[15])));
                if (item.getBfStrings().contains("2:2")) {
                    titlep3.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlep3.setTextColor(Color.WHITE);
                } else {
                    titlep3.setTextColor(Color.BLACK);
                    titlep3.setBackgroundColor(Color.WHITE);
                }
                TextView titlep4 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_33);
                titlep4.setText("3:3\n" + df.format(Double.parseDouble(rqsflists.get(3)[16])));
                if (item.getBfStrings().contains("3:3")) {
                    titlep4.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlep4.setTextColor(Color.WHITE);
                } else {
                    titlep4.setTextColor(Color.BLACK);
                    titlep4.setBackgroundColor(Color.WHITE);
                }
                TextView titlep5 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_p_other);
                titlep5.setText("平其他\n" + df.format(Double.parseDouble(rqsflists.get(3)[17])));
                if (item.getBfStrings().contains("9:9")) {
                    titlep5.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlep5.setTextColor(Color.WHITE);
                } else {
                    titlep5.setTextColor(Color.BLACK);
                    titlep5.setBackgroundColor(Color.WHITE);
                }
                // 负
                TextView titlef1 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_01);
                titlef1.setText("0:1\n" + df.format(Double.parseDouble(rqsflists.get(3)[18])));
                if (item.getBfStrings().contains("0:1")) {
                    titlef1.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef1.setTextColor(Color.WHITE);
                } else {
                    titlef1.setTextColor(Color.BLACK);
                    titlef1.setBackgroundColor(Color.WHITE);
                }
                TextView titlef2 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_02);
                titlef2.setText("0:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[19])));
                if (item.getBfStrings().contains("0:2")) {
                    titlef2.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef2.setTextColor(Color.WHITE);
                } else {
                    titlef2.setTextColor(Color.BLACK);
                    titlef2.setBackgroundColor(Color.WHITE);
                }
                TextView titlef3 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_12);
                titlef3.setText("1:2\n" + df.format(Double.parseDouble(rqsflists.get(3)[20])));
                if (item.getBfStrings().contains("1:2")) {
                    titlef3.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef3.setTextColor(Color.WHITE);
                } else {
                    titlef3.setTextColor(Color.BLACK);
                    titlef3.setBackgroundColor(Color.WHITE);
                }
                TextView titlef4 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_03);
                titlef4.setText("0:3\n" + df.format(Double.parseDouble(rqsflists.get(3)[21])));
                if (item.getBfStrings().contains("0:3")) {
                    titlef4.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef4.setTextColor(Color.WHITE);
                } else {
                    titlef4.setTextColor(Color.BLACK);
                    titlef4.setBackgroundColor(Color.WHITE);
                }
                TextView titlef5 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_13);
                titlef5.setText("1:3\n" + df.format(Double.parseDouble(rqsflists.get(3)[22])));
                if (item.getBfStrings().contains("1:3")) {
                    titlef5.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef5.setTextColor(Color.WHITE);
                } else {
                    titlef5.setTextColor(Color.BLACK);
                    titlef5.setBackgroundColor(Color.WHITE);
                }
                TextView titlef6 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_23);
                titlef6.setText("2:3\n" + df.format(Double.parseDouble(rqsflists.get(3)[23])));
                if (item.getBfStrings().contains("2:3")) {
                    titlef6.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef6.setTextColor(Color.WHITE);
                } else {
                    titlef6.setTextColor(Color.BLACK);
                    titlef6.setBackgroundColor(Color.WHITE);
                }
                TextView titlef7 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_04);
                titlef7.setText("0:4\n" + df.format(Double.parseDouble(rqsflists.get(3)[24])));
                if (item.getBfStrings().contains("0:4")) {
                    titlef7.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef7.setTextColor(Color.WHITE);
                } else {
                    titlef7.setTextColor(Color.BLACK);
                    titlef7.setBackgroundColor(Color.WHITE);
                }
                TextView titlef8 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_14);
                titlef8.setText("1:4\n" + df.format(Double.parseDouble(rqsflists.get(3)[25])));
                if (item.getBfStrings().contains("1:4")) {
                    titlef8.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef8.setTextColor(Color.WHITE);
                } else {
                    titlef8.setTextColor(Color.BLACK);
                    titlef8.setBackgroundColor(Color.WHITE);
                }
                TextView titlef9 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_24);
                titlef9.setText("2:4\n" + df.format(Double.parseDouble(rqsflists.get(3)[26])));
                if (item.getBfStrings().contains("2:4")) {
                    titlef9.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef9.setTextColor(Color.WHITE);
                } else {
                    titlef9.setTextColor(Color.BLACK);
                    titlef9.setBackgroundColor(Color.WHITE);
                }
                TextView titlef10 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_05);
                titlef10.setText("0:5\n" + df.format(Double.parseDouble(rqsflists.get(3)[27])));
                if (item.getBfStrings().contains("0:5")) {
                    titlef10.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef10.setTextColor(Color.WHITE);
                } else {
                    titlef10.setTextColor(Color.BLACK);
                    titlef10.setBackgroundColor(Color.WHITE);
                }
                TextView titlef11 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_15);
                titlef11.setText("1:5\n" + df.format(Double.parseDouble(rqsflists.get(3)[28])));
                if (item.getBfStrings().contains("1:5")) {
                    titlef11.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef11.setTextColor(Color.WHITE);
                } else {
                    titlef11.setTextColor(Color.BLACK);
                    titlef11.setBackgroundColor(Color.WHITE);
                }
                TextView titlef12 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_25);
                titlef12.setText("2:5\n" + df.format(Double.parseDouble(rqsflists.get(3)[29])));
                if (item.getBfStrings().contains("2:5")) {
                    titlef12.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef12.setTextColor(Color.WHITE);
                } else {
                    titlef12.setTextColor(Color.BLACK);
                    titlef12.setBackgroundColor(Color.WHITE);
                }
                TextView titlef13 = (TextView) bfDialog.getCustomView()
                        .findViewById(R.id.jczq_bf_f_other);
                titlef13.setText("负其他\n" + df.format(Double.parseDouble(rqsflists.get(3)[30])));
                if (item.getBfStrings().contains("0:9")) {
                    titlef13.setBackgroundColor(android.graphics.Color
                            .parseColor("#FF0026"));
                    titlef13.setTextColor(Color.WHITE);
                } else {
                    titlef13.setTextColor(Color.BLACK);
                    titlef13.setBackgroundColor(Color.WHITE);
                }
                bfDialog.show();
            }
        });

        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    static class GroupViewHolder {
        private final TextView list_item_parent_title;
        private final ImageView list_item_parent_icon;

        public GroupViewHolder(View view) {
            list_item_parent_title = (TextView) view.findViewById(R.id.list_item_parent_title);
            list_item_parent_icon = (ImageView) view.findViewById(R.id.list_item_parent_icon);
        }
    }

    static class ChlidViewHolder {
        private final TextView item_name;
        private final TextView item_time;
        private final TextView home_team_name;
        private final TextView away_team_name;
        private final TextView jczq_select_bf;


        public ChlidViewHolder(View view) {
            item_name = (TextView) view.findViewById(R.id.item_name);
            item_time = (TextView) view.findViewById(R.id.item_time);
            home_team_name = (TextView) view.findViewById(R.id.home_team_name);
            away_team_name = (TextView) view.findViewById(R.id.away_team_name);
            jczq_select_bf = (TextView) view.findViewById(R.id.jczq_select_bf);
        }
    }

    private void isAdd(ZqCBFItem item) {
        if (item.getBfStrings().size() != 0) {
            if (!Utils.ZQ_BF_ITEM_LIST.contains(item)) {
                Utils.ZQ_BF_ITEM_LIST.add(item);
            }
        } else {
            if (Utils.ZQ_BF_ITEM_LIST.contains(item)) {
                Utils.ZQ_BF_ITEM_LIST.remove(item);
            }
        }
        changed.onClickSetChangedText();
    }
}
